/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.rental.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
*
* @description /
* @author maojinhui
* @date 2020-10-29
**/
@Entity
@Data
@Table(name="bus_rental")
public class Rental extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "user_id")
    @ApiModelProperty(value = "发布人id")
    private String userId;

    @NotBlank(message = "请填写标题")
    @Column(name = "title")
    @ApiModelProperty(value = "标题")
    private String title;

    @NotBlank(message = "请填写联系电话")
    @Column(name = "tel")
    @ApiModelProperty(value = "联系电话")
    private String tel;


    @NotNull(message = "请填写月租金")
    @Column(name = "renet")
    @ApiModelProperty(value = "租金/月")
    private Integer renet;

    @NotBlank(message = "请填写付款方式")
    @Column(name = "pay_type")
    @ApiModelProperty(value = "付款方式")
    private String payType;

    @NotNull(message = "请填写房屋面积")
    @Column(name = "area")
    @ApiModelProperty(value = "房屋面积")
    private Integer area;

    @NotBlank(message = "请填写房型")
    @Column(name = "house_type")
    @ApiModelProperty(value = "房型")
    private String houseType;

    @NotBlank(message = "请填写房屋朝向")
    @Column(name = "toward")
    @ApiModelProperty(value = "房屋朝向")
    private String toward;

    @NotNull(message = "请填写房屋楼层")
    @Column(name = "floor")
    @ApiModelProperty(value = "楼层")
    private Integer floor;

    @NotNull(message = "请填写是否有电梯")
    @Column(name = "has_lift")
    @ApiModelProperty(value = "是否有电梯")
    private Integer hasLift;

    @NotNull(message = "请填写装修情况")
    @Column(name = "decoration")
    @ApiModelProperty(value = "1毛坯房；2简装修；3精装修")
    private Integer decoration;

    @NotBlank(message = "请填写地址")
    @Column(name = "address")
    @ApiModelProperty(value = "地址")
    private String address;



    @Column(name = "status")
    @ApiModelProperty(value = "状态：-1待提交，草稿，0待审核；1审核通过；2审核失败;3已过期")
    private Integer status;

    @Column(name = "start_time")
    @ApiModelProperty(value = "生效时间")
    private Timestamp startTime;

    @Column(name = "end_time")
    @ApiModelProperty(value = "结束时间")
    private Timestamp endTime;

    public void copy(Rental source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}